﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml.Serialization;

namespace zEngine.Particles
{
    public struct ParticleVertex
    {
        public Vector3 Position; // Normal Position
        public Vector2 TexCoord; // 2 floats for texcoord
        public Vector2 LifeTime; //1 float for time created and 1 float for how long the particle alive
        public Vector4 Direction; // 3 floats for direction the particle move, 1 float for random value

        #region Construction
        public ParticleVertex(Vector3 position, Vector2 texCoord, float timeCreated, float lifeTime, Vector3 direction, float randomVal)
        {
            Position = position;
            TexCoord = texCoord;
            LifeTime = new Vector2(timeCreated, lifeTime);
            Direction = new Vector4(direction.X, direction.Y, direction.Z, randomVal);
        }
        #endregion

        public static readonly VertexElement[] VertexElements = new VertexElement[]
        {
            new VertexElement(0, 0, VertexElementFormat.Vector3,VertexElementMethod.Default, VertexElementUsage.Position, 0),
            new VertexElement(0, sizeof(float) * 3, VertexElementFormat.Vector2,VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
            new VertexElement(0, sizeof(float) * (3 + 2), VertexElementFormat.Vector4,VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 1),
            new VertexElement(0, sizeof(float) * (3+ 2 + 2), VertexElementFormat.Vector4,VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 2)
        };
        public static readonly int SizeInBytes = sizeof(float) * (3 + 2 + 2 + 4);
    }
}
